<?
require 'global.php';

$url='featured_products';
$do=isset($_GET["do"])?clean($_GET["do"]):'view';// 备用字段
$id=0; if (isset($_GET["id"])) $id = clean($_GET["id"]);
$page=1; if(isset($_GET["page"]))if(is_numeric($_GET["page"]))$page=$_GET["page"];

$product->rows=16;
$where=array();
$where[]=array('name'=>'is_enabled','val'=>1);
$where[]=array('name'=>'is_featured','val'=>1);
$order_by='id';
$pages=$product->count_pages($where);
$info=$product->get_page($page,$where,$order_by);

// 热销产品 hot_products
$tem = $product->get_rows(32,'is_enabled',1,'sold_quantity','desc');
shuffle($tem);
$arr_hot=array();
$k=0;
foreach($tem as $row) { $arr_hot[]=$row; $k++; if($k==MAX_HOT_PRODUCT_SHOWN_SIDE) break; }

//  历史记录 history
$history=get_history();
$has_history=count($history);
$where=array();
$where[]=array('name'=>'is_enabled','val'=>1);
$where[]=array('name'=>'id','val'=>$history,'opn'=>'in');
$tem = $product->get_rows_advanced(32,$where);
//shuffle($tem);
$arr_history=array();
$k=0;
foreach($tem as $row) { $arr_history[]=$row; $k++; if($k==MAX_RECENTLY_VIEWED_PRODUCT_SHOWN_SIDE) break; }

// SEO 设置 seo tags
$sort_name=WEB_FEATURED_PRODUCTS;
$title=WEB_FEATURED_PRODUCTS.' - '.$config['SITE_TITLE_'.LANG];
$kwd=$title;
$dpn=$kwd;

// view 加载视图
require VIEW.$url.'.php';

// end of file
